import Vue from 'vue';
import VueResource from 'vue-resource';
import router from './router';
import Vuex from 'vuex';
import App from './app';
import VueAwesomeSwiper from 'vue-awesome-swiper';

Vue.use(VueResource);
Vue.use(Vuex);
Vue.use(VueAwesomeSwiper);

// 仓库
let store = new Vuex.Store({
	// 状态
	state: {
		loginState: false,
		regState:false,
		settingState:false,
		status:true,
		userInfo: ''
	},
	// 行为：是用来改变状态
	mutations: {
		changeLoginState(state){
			state.loginState = !state.loginState;
		},
		changeSettingState(state){
			state.settingState = !state.settingState;
		},
		changeState(state,sta){
			state.status = sta;
		},
		changeRegState(state){
			state.regState = !state.regState;
		},
		userName(state,name){
			state.userInfo = name;
		}
	}
});

new Vue({
	el: "#app",
	render:h=>h(App),
	router,
	store,
	swiper:VueAwesomeSwiper,
	mounted(){
		if(localStorage.userInfo){
			this.$store.commit('changeState',false);
			this.$store.commit('userName',localStorage.userInfo);
//			this.userInfo = localStorage.userInfo;
		}else{
			this.$store.commit('changeState',true);
		}
	}
})